package cn.itsource.feign.clients;

import cn.itsource.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
// 交给spring容器管理
@Component
public class HystrixfallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient(){
            // 使用匿名内部类的方法实现接口
            @Override
            public User getuser(Long id) {
                return new User(-1L, "失败", "失败了兄弟");
            }
        };
    }
}
